-
-
Notifications
You must be signed in to change notification settings - Fork 783
Populate buildMeta and buildInfo on ConsumeSharedPlugin using fallbacks #11621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Populate buildMeta and buildInfo on ConsumeSharedPlugin using fallbacks #11621
Conversation
- Add public get_options() method to ConsumeSharedModule for accessing private options field - Fix type mismatches between Ustr and Identifier in module graph operations - Add proper mutability declarations for module graph mutations - Collapse nested if statements to follow clippy style guidelines - Implement finishModules hook to copy build metadata from fallback modules
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes compilation errors in the rspack_plugin_mf crate by resolving type mismatches and private field access issues in the consume shared plugin functionality.
- Adds a new hook for processing ConsumeSharedModule instances during compilation to copy metadata from fallback modules
- Introduces a public API method to access ConsumeSharedModule options that were previously private
- Updates imports to include necessary types for module graph operations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
crates/rspack_plugin_mf/src/sharing/consume_shared_plugin.rs | Adds finish_modules hook implementation and updates imports to support module graph operations |
crates/rspack_plugin_mf/src/sharing/consume_shared_module.rs | Adds public getter method for accessing ConsumeOptions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
// Only process ConsumeSharedModule instances with fallback dependencies | ||
if let Some(consume_shared) = module.as_any().downcast_ref::<ConsumeSharedModule>() { | ||
// Check if this module has a fallback import | ||
if consume_shared.get_options().import.is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks for import.is_some()
but the logic processes modules regardless of whether they have fallback dependencies. Consider adding validation to ensure the module actually has fallback dependencies before adding it to the processing list.
Copilot uses AI. Check for mistakes.
for module_id in consume_shared_modules { | ||
let fallback_module_id = { | ||
let module_graph = compilation.get_module_graph(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module graph is accessed multiple times within the loop (lines 424, 475, 487). Consider restructuring to minimize repeated access to the module graph for better performance.
for module_id in consume_shared_modules { | |
let fallback_module_id = { | |
let module_graph = compilation.get_module_graph(); | |
let module_graph = compilation.get_module_graph(); | |
for module_id in consume_shared_modules { | |
let fallback_module_id = { |
Copilot uses AI. Check for mistakes.
📦 Binary Size-limit
❌ Size increased by 8.00KB from 47.43MB to 47.44MB (⬆️0.02%) |
- Add test configuration for nested consume shared module scenarios - Include package dependencies and ESM/CJS module test setup
CodSpeed Performance ReportMerging #11621 will not alter performanceComparing Summary
|
…raph access; clippy cleanups - Process only modules with fallback import - Compute fallback meta with single graph borrow - Emit warning when fallback not found instead of defaulting - Collapse nested ifs, use Option::map per clippy
Description
ConsumeSharedModule
does not properly populate itsbuildMeta
andbuildInfo
properties during its build. This can cause critical issues inshared
nested module scenarios where packages have complex dependency structures with nestedpackage.json
files (with ESM"type": "module"
exports) as seen in #3779 with@mui/styled-engine
.Root cause
Bundlers rely on this metadata to understand
Module
characteristics such as module type detection (ESM vs CommonJS) andimport/export
statement generation. In the case ofwebpack
and@mui/styled-engine
, without the properbuildMeta
info, it generates incorrect import statements, leading to runtime errors like:Related Issue
module-federation/core#3779
Types of changes
Checklist